package com.bruce.springai.controller;

import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
public class HelloWorldController {

    @Resource
    private DeepSeekChatModel deepseekChatModel;

    @GetMapping("/chat")
    public String chat(@RequestParam(name ="message") String message) {
        return deepseekChatModel.call(message);
    }

    /**
     * 流式输出
     * @param message
     * @return
     */
    @GetMapping(value ="/stream",produces = "text/stream;charset=utf-8")
    public Flux<String> stream(@RequestParam(name ="message") String message) {
        return deepseekChatModel.stream(message);
    }
}
